package com.jwiki.app.rpcui.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;

public abstract class PropertyUtils {

    public static Properties getProperty(File propFile) throws IOException {
        InputStream inStream = new FileInputStream(propFile);
        try {
            Properties prop = new Properties();
            prop.load(inStream);
            return prop;
        } finally {
            inStream.close();
        }
    }

    public static void saveProperty(Properties prop, File propFile) throws IOException {
        saveProperty(prop, null, propFile);
    }

    public static void saveProperty(Properties prop, String comment, File propFile) throws IOException {
        OutputStream outStream = new FileOutputStream(propFile);
        try {
            prop.store(outStream, comment);
        } finally {
            outStream.close();
        }
    }

}
